<?php if (!defined('THINK_PATH')) exit();?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo ($SHOP_NAME); ?>团购管理系统</title>
<link rel="stylesheet" type="text/css" href="__TMPL__ThemeFiles/Css/style.css" />
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/Base.js"></script>
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/prototype.js"></script>
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/mootools.js"></script>
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/Ajax/ThinkAjax.js"></script>
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/common.js"></script>
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/Util/ImageLoader.js"></script>
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/kindeditor/kindeditor.js"></script>
<script language="JavaScript">
<!--
//指定当前组模块URL地址 
var URL = '__URL__';
var ROOT_PATH = '__ROOT__';
var APP	 =	 '__APP__';
var PUBLIC = '__TMPL__ThemeFiles';
ThinkAjax.image = [	 '__TMPL__ThemeFiles/Images/loading2.gif', '__TMPL__ThemeFiles/Images/ok.gif','__TMPL__ThemeFiles/Images/update.gif' ]
ImageLoader.add("__TMPL__ThemeFiles/Images/bgline.gif","__TMPL__ThemeFiles/Images/bgcolor.gif","__TMPL__ThemeFiles/Images/titlebg.gif");
ImageLoader.startLoad();
var VAR_MODULE = '<?php echo c('VAR_MODULE');?>';
var VAR_ACTION = '<?php echo c('VAR_ACTION');?>';
var CURR_MODULE = '<?php echo ($module_name); ?>';
//-->
</script>
<script language="JavaScript">
//定义JS中使用的语言变量
var VIEW = '<?php echo (L("VIEW")); ?>';
var CONFIRM_DELETE = '<?php echo (L("CONFIRM_DELETE")); ?>';
var CONFIRM_DELETE_IMAGE = '<?php echo (L("CONFIRM_DELETE_IMAGE")); ?>';
var NO_SELECT = '<?php echo (L("NO_SELECT")); ?>';
var CHOOSE_RECYCLE_ITEM = '<?php echo (L("CHOOSE_RECYCLE_ITEM")); ?>';
var SELECT_EDIT_ITEM = '<?php echo (L("SELECT_EDIT_ITEM")); ?>';
var SELECT_DEL_ITEM	=	'<?php echo (L("SELECT_DEL_ITEM")); ?>';
var CONFIRM_DELETE_FILE = '<?php echo (L("CONFIRM_DELETE_FILE")); ?>';
var CONFIRM_FOREVER_DELETE = '<?php echo (L("CONFIRM_FOREVER_DELETE")); ?>';
var CONFIRM_DELETE_USER_DATA = '<?php echo (L("CONFIRM_DELETE_USER_DATA")); ?>';
var CONFIRM_RESTORE = '<?php echo (L("CONFIRM_RESTORE")); ?>';
var ATTR_PRICE	=	'<?php echo L("ATTR_PRICE");?>';
var ATTR_STOCK	=	'<?php echo L("ATTR_STOCK");?>';
</script>
</head>

<body onload="loadBar(0)">

<div id="loader" ><?php echo (L("PAGE_LOADING")); ?></div>
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/jquery.js"></script>
<script type="text/javascript" src="__TMPL__ThemeFiles/Js/jquery.json.js"></script>
<!-- 菜单区域  -->
<style type="text/css">
th,p{text-align:center;}
table.list td{text-align:center;}
table.list td img{cursor:pointer;}
</style>
<!-- 主页面开始 -->
<div id="main" class="main" >
<!-- 主体内容  -->
<div class="content" >
<div class="title"><?php echo (L("DATA_LIST")); ?></div>
<!--  功能操作区域  -->
<div class="operate" >
<div style="float:left;">
<input type="button" id="" name="add" value="<?php echo (L("_ADD_DATA")); ?>" onclick="addData()" class="add imgButton">
<input type="button" id="" name="edit" value="<?php echo (L("_EDIT_DATA")); ?>" onclick="editData()" class="edit imgButton">
<input type="button" id="" name="delete" value="<?php echo (L("_DELETE_DATA")); ?>" onclick="delData()" class="delete imgButton">
<!--<input type="button" id="" name="delete" value="审核" onclick="updateGoodsStatus(1)" class="search">
<input type="button" id="" name="delete" value="取消审核" onclick="updateGoodsStatus(0)" class="sendemail">-->
</div>
<!-- 查询区域 -->
<form method='get' action="__APP__" style="float:right; position:relative;">
<select name="city" id="city">
	<option value="0" >请选择城市</value>
    <?php if(is_array($group_city_list)): foreach($group_city_list as $key=>$city_list): ?><option value="<?php echo ($city_list["name"]); ?>" <?php if($city_list['name'] == $city): ?>selected<?php endif; ?> ><?php echo ($city_list["name"]); ?></value><?php endforeach; endif; ?>
</select>
<select name="status">
	<option value="-1" <?php if($status == -1 ): ?>selected<?php endif; ?>>=审核状态=</value>
	<option value="0" <?php if($status == 0): ?>selected<?php endif; ?>>未审核</option>
    <option value="1" <?php if($status == 1): ?>selected<?php endif; ?>>已审核</option>
</select>
<select name="cate_id" id="cate_id">
	<option value="0"><?php echo (L("CATE_ALL")); ?></value>
    <?php if(is_array($goodsCates)): foreach($goodsCates as $key=>$cate): ?><option value="<?php echo ($cate["id"]); ?>" <?php if($cate['id'] == $cate_id): ?>selected<?php endif; ?>><?php echo ($cate["name"]); ?></value><?php endforeach; endif; ?>
</select>
<?php echo (L("SITE_ID")); ?>:<input type="text" name="site_name" class="medium" value = "<?php echo ($site_name); ?>" style="width:80px;">&nbsp;
<?php echo (L("GOODS_NAME")); ?>:<input type="text" name="name" class="medium" value = "<?php echo ($name); ?>" style="width:80px;">&nbsp;
<input type="hidden" name="SEARCH_TYPE" value="like" />
<input type="submit" id="" name="search" value="<?php echo (L("_SEARCH_DATA")); ?>" onclick="" class="search imgButton">
<!-- 高级查询区域 -->
<input type="hidden" name="<?php echo c('VAR_MODULE');?>" value="Goods" />
<input type="hidden" name="<?php echo c('VAR_ACTION');?>" value="now" />
</form>
</div>

</div>

<!-- 功能操作区域结束 -->

<!-- 列表显示区域  -->
<div class="list" >
<!-- Think 系统列表组件开始 -->
<table id="checkList" class="list" cellpadding=0 cellspacing=0 ><tr><td height="5" colspan="13" class="topTd" ></td></tr><tr class="row" ><th width="8"><input type="checkbox" id="check" onclick="CheckAll('checkList')"></th><th width="40"><a href="javascript:sortBy('id','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("ID")); ?><?php echo ($sortType); ?> "><?php echo (L("ID")); ?><?php if(($order)  ==  "id"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('name','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("NAME")); ?><?php echo ($sortType); ?> "><?php echo (L("NAME")); ?><?php if(($order)  ==  "name"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width="80"><a href="javascript:sortBy('site_name','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("SITE_ID")); ?><?php echo ($sortType); ?> "><?php echo (L("SITE_ID")); ?><?php if(($order)  ==  "site_name"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width="80"><a href="javascript:sortBy('city','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("CITY")); ?><?php echo ($sortType); ?> "><?php echo (L("CITY")); ?><?php if(($order)  ==  "city"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width="90"><a href="javascript:sortBy('cate_id','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("CATE_ID")); ?><?php echo ($sortType); ?> "><?php echo (L("CATE_ID")); ?><?php if(($order)  ==  "cate_id"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width="80"><a href="javascript:sortBy('shop_price','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("SHOP_PRICE")); ?><?php echo ($sortType); ?> "><?php echo (L("SHOP_PRICE")); ?><?php if(($order)  ==  "shop_price"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th><a href="javascript:sortBy('bought','<?php echo ($sort); ?>','now')" title="按照已购人数<?php echo ($sortType); ?> ">已购人数<?php if(($order)  ==  "bought"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width="100"><a href="javascript:sortBy('end_time','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("END_TIME")); ?><?php echo ($sortType); ?> "><?php echo (L("END_TIME")); ?><?php if(($order)  ==  "end_time"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width="50"><a href="javascript:sortBy('sort','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("SORT")); ?><?php echo ($sortType); ?> "><?php echo (L("SORT")); ?><?php if(($order)  ==  "sort"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width="50"><a href="javascript:sortBy('is_best','<?php echo ($sort); ?>','now')" title="按照推荐<?php echo ($sortType); ?> ">推荐<?php if(($order)  ==  "is_best"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width="50"><a href="javascript:sortBy('status','<?php echo ($sort); ?>','now')" title="按照<?php echo (L("STATUS")); ?><?php echo ($sortType); ?> "><?php echo (L("STATUS")); ?><?php if(($order)  ==  "status"): ?><img src="__TMPL__ThemeFiles/Images/<?php echo ($sortImg); ?>.gif" width="12" height="17" border="0" align="absmiddle"><?php endif; ?></a></th><th width='60'>操作</th></tr><?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$goods): ++$i;$mod = ($i % 2 )?><tr class="row" onmouseover="over(event)" onmouseout="out(event)" onclick="change(event)" ><td><?php if(($goods['level'] == '0')or($goods['level'] > 0)): ?><?php else: ?><input type="checkbox" class="key" name="key"	value="<?php echo ($goods["id"]); ?>" <?php if($goods['checked']): ?>checked="checked"<?php endif; ?> ><?php endif; ?></td><td rel="id"><?php echo ($goods["id"]); ?></td><td rel="name"><a href="javascript:edit('<?php echo (addslashes($goods["id"])); ?>')"><?php echo ($goods["name"]); ?></a></td><td rel="site_name"><?php echo ($goods["site_name"]); ?></td><td rel="city"><?php echo ($goods["city"]); ?></td><td rel="cate_id"><?php echo ($goods["cate_id"]); ?></td><td rel="shop_price|priceFormat"><?php echo (priceFormat($goods["shop_price"])); ?></td><td rel="bought"><?php echo ($goods["bought"]); ?></td><td rel="end_time|toDate"><?php echo (toDate($goods["end_time"])); ?></td><td rel="sort"><?php echo ($goods["sort"]); ?></td><td rel="is_best|getBest"><?php echo (getBest($goods["is_best"])); ?></td><td rel="status|getStatus"><?php echo (getStatus($goods["status"])); ?></td><td><a href="javascript:edit('<?php echo ($goods["id"]); ?>')"><?php echo (L("_EDIT_DATA")); ?></a>&nbsp;<a href="javascript: del('<?php echo ($goods["id"]); ?>')"><?php echo (L("_DELETE_DATA")); ?></a>&nbsp;</td></tr><?php endforeach; endif; else: echo "" ;endif; ?><tr><td height="5" colspan="13" class="bottomTd"></td></tr></table>
<!-- Think 系统列表组件结束 -->
 
</div>

<!--  分页显示区域 -->
<div class="page"><?php echo ($page); ?></div>
<!-- 列表显示区域结束 -->
</div>
<!-- 主体内容结束 -->
</div>
<!-- 主页面结束 -->
<script type="text/javascript">
jQuery(function($){
	var statusTooltip = ["<?php echo L("FORBID");?>","<?php echo L("NORMAL");?>"];
	var statusImages = ["__TMPL__ThemeFiles/Images/locked.gif","__TMPL__ThemeFiles/Images/ok.gif"];
	var bestTooltip = ["未推荐","已推荐"];
	var goodsCateSelect = $("#cate_id").clone();
	$("option",goodsCateSelect).attr("selected",false);
	$("option",goodsCateSelect).eq(0).html("=选择分类=");
	
	$("td[rel='cate_id']").each(function(i){
		var thisTD = $(this);
		var cateID = parseInt(thisTD.text());
		var thisSelect = goodsCateSelect.clone();
		if(cateID > 0)
			$("option",thisSelect).eq(0).remove();
			
		$("option[value='"+cateID+"']",thisSelect).attr("selected",true);
		thisTD.html(thisSelect);
		thisSelect.change(function(){
			var goodsID = $("input",thisTD.parent()).val();
			$.ajax({
				url: APP+"?"+VAR_MODULE+"=Goods&"+VAR_ACTION+"=updateGoodsCate&id="+goodsID+"&cate_id="+this.value,
				cache: false,
				success:function(data)
				{
					if(data == 1)
					{
						var firstOption = $("option",thisSelect).eq(0);
						if(firstOption.val() == 0)
							firstOption.remove();
					}
				}
			});
		});
	});
	
	$("td[rel='sort']").each(function(i){
		var thisTD = $(this);
		var sortID = parseInt(thisTD.text());
		var thisInput = $("<input type='text' style='width:40px;' value='"+sortID+"'>");
		thisTD.html(thisInput);
		thisInput.blur(function(){
			var goodsID = $("input",thisTD.parent()).val();
			$.ajax({
				url: APP+"?"+VAR_MODULE+"=Goods&"+VAR_ACTION+"=updateGoodsSort&id="+goodsID+"&sort="+this.value,
				cache: false,
				success:function(data)
				{
				}
			});
		});
		
	});
	
	$("td[rel='status|getStatus']").click(function(){
		var thisTD = $(this);							 
		var id = $("input",thisTD.parent()).val();
		
		$.ajax({
			url: APP+"?"+VAR_MODULE+"=Goods&"+VAR_ACTION+"=updateGoodsStauts&id="+id,
			cache: false,
			success:function(data)
			{
				if(data != "err")
				{
					$("img",thisTD).attr({"src":statusImages[data],"title":statusTooltip[data]});
				}
			}
		});			 
	});
	
	
	$("td[rel='is_best|getBest']").click(function(){
		var thisTD = $(this);							 
		var id = $("input",thisTD.parent()).val();
		
		$.ajax({
			url: APP+"?"+VAR_MODULE+"=Goods&"+VAR_ACTION+"=updateGoodsBest&id="+id,
			cache: false,
			success:function(data)
			{
				if(data != "err")
				{
					$("img",thisTD).attr({"src":statusImages[data],"title":bestTooltip[data]});
				}
			}
		});			 
	});
});
</script>